<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.hospital.util.*" %>
<%@ page import="java.util.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<link href="images/main.css" rel="stylesheet" type="text/css" />
<link  href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/trim.js"></script>
<script language="javascript" type="text/javascript" src="../My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
	function validate() {
		var houseId1 = document.getElementById("houseId1");
		var houseId2 = document.getElementById("houseId2");
		var houseId3 = document.getElementById("houseId3");
		var num = document.getElementById("num");
		var number = houseId1.value + houseId2.value + houseId3.value + num.value;
		if (trim(number).length != 0) {
			var xmlHttpRequest = null;
			var url = "../BedHouseIDIsExistServlet?number=" + number;
			var bedhousemsg = document.getElementById("bedhousemsg");
			if (window.XMLHttpRequest) {//表示当前浏览器不是IE
				xmlHttpRequest = new XMLHttpRequest();
			} else if (window.ActiveXObject) {
				xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
			}
			xmlHttpRequest.open("GET", url, true);//设置请求方式为GET，设置请求的URL，设置为异步提交
			xmlHttpRequest.onreadystatechange = function(){//将方法地址复制给onreadystatechange属性
				if(xmlHttpRequest.readyState == 4){//Ajax引擎状态为成功
					if(xmlHttpRequest.status == 200){//HTTP协议状态为成功
						if(trim(xmlHttpRequest.responseText) != ""){
							bedhousemsg.innerHTML = "<font color='red'>" + trim(xmlHttpRequest.responseText) + "</font>";
						}else{
							bedhousemsg.innerHTML = "恭喜您，病房号可以使用。 ";
						}
					}else{
						alert("请求失败，错误码=" + xmlHttp.status);
					}
				}
			};
			xmlHttpRequest.send(null);//将设置信息发送到Ajax引擎
		}else{
			bedhousemsg.innerHTML = "";
		}
	}
	function sub(){
		var houseId1 = document.getElementById("houseId1");
		var houseId2 = document.getElementById("houseId2");
		var houseId3 = document.getElementById("houseId3");
		var money = document.getElementById("money");
		if(trim(houseId1.value).length == 0){
			alert("楼号不能为空。");
			houseId1.focus();
		}else if(trim(houseId2.value).length == 0){
			alert("层号不能为空。");
			houseId2.focus();
		}else if(trim(houseId3.value).length == 0){
			alert("区域不能为空。");
			houseId3.focus();
		}else if(bedhousemsg.innerHTML.length != 13){
			alert("病房号已经存在。");
			num.focus();
		}else if(trim(money.value).length == 0){
			alert("病房价格不能为空。");
			money.focus();
		}else{
			document.forms["form"].submit();
		}
	}
</script>
</head>
<body onload="init();">
	<jsp:include page="right_top.jsp"></jsp:include>
	<!-- TOP START -->
	<div id="right_font">
		<img src="images/main_14.gif" /> 您现在所在的位置：首页 → 住院信息管理 → <span class="bfont">增加住院病房</span> 
	</div>
	<!-- TOP END -->
	<hr>
	<form action="InhospitableServlet?method=add" method="post" name="form" id="form">
		<table style="margin-top: 30px;">
			<tr height="30px;">
				<td><font color="#FF0000">*</font>病房号&nbsp;  ：</td>
				<td>
				<select name="houseId1" id="houseId1" onclick="validate()">
					<option value="01">1号</option>
					<option value="02">2号</option>
					<option value="03">3号</option>
					<option value="04">4号</option>
				</select>号楼
				<select name="houseId2" id="houseId2" onclick="validate()">
					<option value="01">1层</option>
					<option value="02">2层</option>
					<option value="03">3层</option>
					<option value="04">4层</option>
					<option value="05">5层</option>
					<option value="06">6层</option>
					<option value="07">7层</option>
					<option value="08">8层</option>
					<option value="09">9层</option>
					<option value="10">10层</option>
					<option value="11">11层</option>
					<option value="12">12层</option>
				</select>层
				<select name="houseId3" id="houseId3" onclick="validate()">
					<option value="11">高度隔离</option>
					<option value="12">CCU病危</option>
					<option value="13">辐射区域</option>
					<option value="14">一般病区</option>
				</select>区域
				</td>
				<td>&nbsp;</td>
			</tr>
			<tr height="30px;">
				<td><font color="#FF0000">*</font>病房序号：</td>
				<td>
					<select name="num" id="num" size="1" onclick="validate()">
						<option value="01">1</option>
						<option value="02">2</option>
						<option value="03">3</option>
						<option value="04">4</option>
						<option value="05">5</option>
						<option value="06">6</option>
						<option value="07">7</option>
						<option value="08">8</option>
						<option value="09">9</option>
						<option value="10">10</option>
						<option value="11">11</option>
						<option value="12">12</option>
					</select>
					<span id="bedhousemsg"></span>
				</td>
				<td width="220px;">&nbsp;</td>
			</tr>
			<tr height="30px;">
				<td><font color="#FF0000">*</font>病房床位数：</td>
				<td>
					<select name="count" id="count">
						<option value="1">1个床位</option>
						<option value="2">2个床位</option>
						<option value="3">3个床位</option>
						<option value="4">4个床位</option>
						<option value="6">6个床位</option>
						<option value="12">12个床位</option>
					</select>
				</td>
				<td>&nbsp;</td>
			</tr>
			<tr height="30px;">
				<td><font color="#FF0000">*</font>病房档次：</td>
				<td>
					<select name="version" id="version">
						<option value="高级">高级</option>
						<option value="普通">普通</option>
					</select>
				</td>
				<td>&nbsp;</td>
			</tr>
			<tr height="30px;">
				<td><font color="#FF0000">*</font>病房价格：</td>
				<td><input type="text" name="money" id="money"></td>
				<td>&nbsp;</td>
			</tr>
			<tr height="30px;">
				<td colspan="2" align="center">
					<input type="button" value="提交" onclick="sub();"/>&nbsp;&nbsp;
					<input type="button" value="返回" onclick="history.go(-1);" />
				</td>
				<td>&nbsp;</td>
			</tr>
		</table>
	</form>
</body>
</html>